
import wx


class InsertFrame(wx.Frame):

    def __init__(self, parent, id):
        wx.Frame.__init__(self, parent, id, 'Button Frame', size=wx.DefaultSize)
        panel = wx.Panel(self)
        button = wx.Button(parent=panel, label='Close', pos=(100, 100), size=(50,25))
        #绑定按钮的单机事件
        self.Bind(wx.EVT_BUTTON, self.onCloseMe, button)
        #绑定窗口的关闭事件
        self.Bind(wx.EVT_CLOSE, self.onCloseWindow)

    def onCloseMe(self, event):
        self.Close()    #关闭这个窗口

    def onCloseWindow(self, event):
        self.Destroy()  #销毁这个窗口


if __name__ == '__main__':
    app = wx.App()
    app.frame = InsertFrame(None, -1)
    app.frame.Show()
    app.MainLoop()